﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UIShare;
using EFong.View.Proxy;

namespace EFong.View.Base
{
    public partial class Frm_CurrencyManager : BasicMdiChildForm
    {
        private Proxy.BaseServiceProxy _baseProxy {get{ return Proxy.BaseServiceProxy.GetInstance();}}

        public Frm_CurrencyManager()
        {
            InitializeComponent();
        }

        protected override void InitFields()
        {
        }

        
        protected override void LoadDatas()
        {
            base.LoadDatas();
            bds_Currency.BindingData(_baseProxy.GetAllCurrency().ReturnValue);
        }

        private void bar_Main_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            switch (e.Item.Name)
            {
                case "bbt_Save":
                    this.save();
                    break;
                case "bbt_Close":
                    this.Close();
                    break;
                default:
                    break;
            }
        }

        private void save()
        {
            UIOperManager.SaveData(
                    () =>
                        {
                            this.gv_Exchanges.PostEditor();

                           return  _baseProxy.UpdateExchangeRate(bds_Currency.DataSource as List<Contract.Currency>).IsSuccess;
                        },
                    MsgResource.Save_Complete
                );
        }
    }
}
